package com.ruoyi.web.controller.owner;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.PropertyFeedback;
import com.ruoyi.system.service.IPropertyFeedbackService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 留言反馈Controller
 * 
 * @author ruoyi
 * @date 2025-10-27
 */
@RestController
@RequestMapping("/system/feedback")
public class PropertyFeedbackController extends BaseController
{
    @Autowired
    private IPropertyFeedbackService propertyFeedbackService;

    /**
     * 查询留言反馈列表
     */
    @PreAuthorize("@ss.hasPermi('system:feedback:list')")
    @GetMapping("/list")
    public TableDataInfo list(PropertyFeedback propertyFeedback)
    {
        startPage();
        List<PropertyFeedback> list = propertyFeedbackService.selectPropertyFeedbackList(propertyFeedback);
        return getDataTable(list);
    }

    /**
     * 导出留言反馈列表
     */
    @PreAuthorize("@ss.hasPermi('system:feedback:export')")
    @Log(title = "留言反馈", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PropertyFeedback propertyFeedback)
    {
        List<PropertyFeedback> list = propertyFeedbackService.selectPropertyFeedbackList(propertyFeedback);
        ExcelUtil<PropertyFeedback> util = new ExcelUtil<PropertyFeedback>(PropertyFeedback.class);
        util.exportExcel(response, list, "留言反馈数据");
    }

    /**
     * 获取留言反馈详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:feedback:query')")
    @GetMapping(value = "/{feedbackId}")
    public AjaxResult getInfo(@PathVariable("feedbackId") Long feedbackId)
    {
        return success(propertyFeedbackService.selectPropertyFeedbackByFeedbackId(feedbackId));
    }

    /**
     * 新增留言反馈
     */
    @PreAuthorize("@ss.hasPermi('system:feedback:add')")
    @Log(title = "留言反馈", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PropertyFeedback propertyFeedback)
    {
        return toAjax(propertyFeedbackService.insertPropertyFeedback(propertyFeedback));
    }

    /**
     * 修改留言反馈
     */
    @PreAuthorize("@ss.hasPermi('system:feedback:edit')")
    @Log(title = "留言反馈", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PropertyFeedback propertyFeedback)
    {
        return toAjax(propertyFeedbackService.updatePropertyFeedback(propertyFeedback));
    }

    /**
     * 删除留言反馈
     */
    @PreAuthorize("@ss.hasPermi('system:feedback:remove')")
    @Log(title = "留言反馈", businessType = BusinessType.DELETE)
	@DeleteMapping("/{feedbackIds}")
    public AjaxResult remove(@PathVariable Long[] feedbackIds)
    {
        return toAjax(propertyFeedbackService.deletePropertyFeedbackByFeedbackIds(feedbackIds));
    }
}
